﻿namespace SX.Core.Caching
{
    public interface ICacheManager
    {
        /// <summary>
        /// 通过key 获取值
        /// </summary>
        /// <typeparam name="T">Type</typeparam>
        /// <param name="key">key</param>
        /// <returns></returns>
        T Get<T>(string key);

        /// <summary>
        /// 保持数据到缓存
        /// </summary>
        /// <param name="key"></param>
        /// <param name="data"></param>
        /// <param name="cacheTime"></param>
        void Set(string key, object data, int cacheTime);

        /// <summary>
        /// 判断key是否使用
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        bool IsSet(string key);

        /// <summary>
        /// 通过key删除缓存
        /// </summary>
        /// <param name="key"></param>
        void Remove(string key);

        /// <summary>
        /// 通过模式批量删除缓存
        /// </summary>
        /// <param name="pattern"></param>
        void RemoveByPattern(string pattern);
        /// <summary>
        /// 清除所有缓存
        /// </summary>
        void Clear();
    }
}
